package org.jetlinks.protocol.official.mqtt;

import org.jetlinks.protocol.official.mqtt.up.UpTopicMessageEnum;

/**
 * @Author bingzhong
 * @Date 2024/12/30 19:27
 * @Description
 */
public class TopicMatcher {

    public static UpTopicMessageEnum match(String topic) {

        for (UpTopicMessageEnum topicMessageEnum : UpTopicMessageEnum.values()) {
            if (topic.startsWith(topicMessageEnum.getTopicPrefix())) {
                return topicMessageEnum;
            }
        }
        throw new UnsupportedOperationException("不支持的topic:" + topic);
    }

}
